package com.kfm.exec;

import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.function.Consumer;

public class PersonTest {

    public static void main(String[] args) {
        Person p1 = new Person("sky", 18, '男');
        Person p2 = new Person("zyp", 17, '女');
        Person p3 = new Person("xwq", 17, '男');
        Person p4 = new Person("bxy", 17, '女');
        Person p5 = new Person("yyp", 17, '女');

        LinkedList list = new LinkedList<>();
        list.add(p1);
        list.add(p2);
        list.add(p3);
        list.add(p4);
        list.add(p5);

        // 排序
        Collections.sort(list);


        // Collections.sort(list, new Comparator<Object>() {
        //     @Override
        //     public int compare(Object o1, Object o2) {
        //         return ((Person)o1).getAge() - ((Person)o2).getAge();
        //     }
        // });

        list.forEach(new Consumer() {
            @Override
            public void accept(Object o) {
                System.out.println(o);
            }
        });
    }
}
